
export class Controller {
    constructor($canvas) {
        this.$canvas = $canvas;
        this.pressed_keys = new Set();
        this.start();
    }
    start() {
        let outer = this;
        this.$canvas.keydown(function(e) { //按下某个元素后，就添加进集合中
            outer.pressed_keys.add(e.key);
            console.log(e.key);
        })

        this.$canvas.keyup(function(e){
            outer.pressed_keys.delete(e.key); // 某个键被按过后，从集合中移除
        })
    }
}